﻿using System;
using System.Web;
using System.Web.Routing;

namespace HeThongSpa
{
    public class Global : HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        protected void Session_Start(object sender, EventArgs e)
        {
            Response.RedirectToRoute(Session["username"] != null ? "TrangChu" : "DangNhap");
        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }

        static void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("DangNhap", "", "~/Site/DangNhap.aspx");
            routes.MapPageRoute("TrangChu", "trang-chu", "~/Site/TrangChu.aspx");
            routes.MapPageRoute("ThongTinCaNhan", "thong-tin-ca-nhan", "~/Site/ThongTinCaNhan.aspx");
            routes.MapPageRoute("DoiMatKhau", "doi-mat-khau", "~/Site/DoiMatKhau.aspx");
            // Khách hàng
            routes.MapPageRoute("DanhSachKhachHang", "quan-ly-khach-hang/khach-hang/danh-sach", "~/QuanLyKhachHang/KhachHang/DanhSachKhachHang.aspx");
            // Danh mục
            routes.MapPageRoute("DanhMucChucVu", "quan-tri-he-thong/danh-muc/chuc-vu", "~/QuanTriHeThong/DanhMuc/DanhMucChucVu.aspx");
            routes.MapPageRoute("DanhMucDichVu", "quan-tri-he-thong/danh-muc/dich-vu", "~/QuanTriHeThong/DanhMuc/DanhMucDichVu.aspx");
            routes.MapPageRoute("DanhMucDonVi", "quan-tri-he-thong/danh-muc/don-vi", "~/QuanTriHeThong/DanhMuc/DanhMucDonVi.aspx");
            routes.MapPageRoute("DanhMucKho", "quan-tri-he-thong/danh-muc/kho", "~/QuanTriHeThong/DanhMuc/DanhMucKho.aspx");
            routes.MapPageRoute("DanhMucLoaiSanPham", "quan-tri-he-thong/danh-muc/loai-san-pham", "~/QuanTriHeThong/DanhMuc/DanhMucLoaiSanPham.aspx");
            routes.MapPageRoute("DanhMucNhaCungCap", "quan-tri-he-thong/danh-muc/nha-cung-cap", "~/QuanTriHeThong/DanhMuc/DanhMucNhaCungCap.aspx");
            routes.MapPageRoute("DanhMucNhomDichVu", "quan-tri-he-thong/danh-muc/nhom-dich-vu", "~/QuanTriHeThong/DanhMuc/DanhMucNhomDichVu.aspx");
            routes.MapPageRoute("DanhMucNhomSanPham", "quan-tri-he-thong/danh-muc/nhom-san-pham", "~/QuanTriHeThong/DanhMuc/DanhMucNhomSanPham.aspx");
            routes.MapPageRoute("DanhMucPhong", "quan-tri-he-thong/danh-muc/phong", "~/QuanTriHeThong/DanhMuc/DanhMucPhong.aspx");
            routes.MapPageRoute("DanhMucSanPham", "quan-tri-he-thong/danh-muc/san-pham", "~/QuanTriHeThong/DanhMuc/DanhMucSanPham.aspx");
            routes.MapPageRoute("DanhMucTaiKhoan", "quan-tri-he-thong/danh-muc/tai-khoan", "~/QuanTriHeThong/DanhMuc/DanhMucTaiKhoan.aspx");
            routes.MapPageRoute("DanhMucThue", "quan-tri-he-thong/danh-muc/thue", "~/QuanTriHeThong/DanhMuc/DanhMucThue.aspx");
            routes.MapPageRoute("DanhMucCuaHang", "quan-tri-he-thong/danh-muc/cua-hang", "~/QuanTriHeThong/DanhMuc/DanhMucCuaHang.aspx");
            // Hệ thống
            routes.MapPageRoute("LichSuHeThong", "quan-tri-he-thong/he-thong/lich-su", "~/QuanTriHeThong/HeThong/LichSuHeThong.aspx");
        }
    }
}